package ru.st.selenium.pages;

import static org.openqa.selenium.support.ui.ExpectedConditions.*;

import org.openqa.selenium.By;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.support.FindBy;

public class MovieEditPage extends InternalPage {

	public MovieEditPage(PageManager pages) {
		super(pages);
	}
	
	@FindBy(name = "name")
	private WebElement nameField;
	
	@FindBy(name = "year")
	private WebElement yearField;
	
	@FindBy(name = "submit")
	private WebElement submitButton;
	
	public String getTitlename() {
		    return nameField.getAttribute("value");
		  }
	  
	public String getYearname() {
		    return yearField.getAttribute("value");
		  }

	public MovieEditPage clickSubmitButton() {
			submitButton.click();
			return this;
		  }

  public MovieEditPage ensurePageLoaded() {
    super.ensurePageLoaded();
    wait.until(presenceOfElementLocated(By.cssSelector("img[alt=\"Save\"]")));
    wait.until(presenceOfElementLocated(By.cssSelector("img[alt=\"Remove\"]")));
    return this;
  }
}
